/*
 * @Author: your name
 * @Date: 2021-10-21 11:20:38
 * @LastEditTime: 2021-10-21 16:49:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /a1902-a-group/vue_domei18n_style/src/mixin/index.js
 */

/**
 * @description: 切换中英文
 * @param {*}
 * @return {*}
 */
export const myChangeMixin = {
    methods: {
        qiehuan(value) {
            this.$i18n.locale = value;
        }
    },
}

/**
 * @description: 切换主题功能
 * @param {*}
 * @return {*}
 */

export const styleMixin = {
    methods: {
        // 切换主题方法
        styleModeChange(style) {
            this.nightModeStyle = style;
            if(style) {
                // 暗夜模式
                this.stylespan = 'daily_item_span dark_item_span';
                this.stylespans = 'daily_item_spans dark_item_spans';
                this.samllLien = 'samll_lien dark_samll';
                document.getElementsByTagName('body')[0].className = "night-mode-style"
            } else {
                // 日间模式
                this.stylespan = 'daily_item_span';
                this.stylespans = 'daily_item_spans';
                this.samllLien = 'samll_lien';
                document.getElementsByTagName('body')[0].className = "mode-style"
            }
        }
    },
    beforeCreate() {
        if(this.nightModeStyle) {
            // 暗夜模式
            document.getElementsByTagName('body')[0].className = "night-mode-style"
        } else {
            // 日间模式
            document.getElementsByTagName('body')[0].className = "mode-style"
        }
    },
    created() {
        this.nightModeStyle = false;
        window['styleModeChange'] = (nightModeStyle) => {
            this.styleModeChange(nightModeStyle);
        }
        
    },
}